package ioperation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOPeration{
    public void work(BookList bookList){
        Scanner scanner=new Scanner(System.in);
        System.out.println("归还图书....");
        System.out.println("请输入你要归还的书：");
        String name=scanner.nextLine();
        int currentsize= bookList.getUseSize();
        for (int c = 0; c < currentsize; c++) {
            Book book = bookList.getBooks(c);
            if (book.getName().equals(name)) {
                if(book.isBorrowed()==true){
                    book.setBorrowed(false);
                    System.out.println("归还成功");
                    return;
                }
            }
        }
    }
}
